<template>
    <div>
        <textarea name="" id="" cols="30" rows="10" v-model="content"></textarea>
        <button @click="addComment">点击评论</button>
    </div>
</template>
<script>
import * as api from "@/api/comment"
import { mapActions } from "vuex"
    export default {
        data(){
            return{
                content:"",
                name:"灵城首富蒋大少"
            }
        },
        methods:{
            ...mapActions("comment",["FETCH_COMMENT"]),
            async addComment(){
                let res = await api.addComment(this.content,this.name)
                console.log(res)
                if(res.data.state){
                    //添加成功，重新获取列表，更新数据
                    this.FETCH_COMMENT()
                }
            }
        }
    }
</script>